package com.cf.interceptor;

import com.cf.domain.vo.UserVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;

@Component
@Slf4j
public class LoginInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String path = request.getRequestURI();
        StringBuffer info = new StringBuffer();
        HttpSession session = request.getSession();
        Object user = session.getAttribute("user");

        if(user == null){
            response.sendRedirect("/uis/loginUI");
            return false;
        }
        return true;
    }
}
